can`t use && in if statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • isitha
    New Member
    • Dec 2010
    • 9

    can`t use && in if statement

    Code:
     
     if (myDataReader.GetString(0) = empID && myDataReader.GetString(1) = shiftID && myDataReader.GetFloat(2) = Final11)
    guyz y cant i do these??
    here empID ,shiftID are originally int values in the FINALCALC table (those are the values to be expected to retrieve by myDataReader.Ge tString(0) n myDataReader.Ge tString(1)). But variable empID and shiftID are String variables which i take from two input text boxes.
  • bentleyw
    New Member
    • Feb 2008
    • 32

    #2
    I think maybe it's because of the '=' instead of '=='. If you are indeed trying to compare each value, give this a try instead:
    Code:
    if ((myDataReader.GetString(0) == empID) && (myDataReader.GetString(1) == shiftID) && (myDataReader.GetFloat(2) == Final11))
    Last edited by bentleyw; Dec 18 '10, 03:08 PM. Reason: Problem was different.

    Comment

    • Subin Ninan
      New Member
      • Sep 2010
      • 91

      #3
      You need to use "==" operator to check for equality. "=" operator is used to assign values.
      Also, you need to group conditions in parenthesis "(a>b)&&(b> c)" to use logical operators like !, &, |, &&, ||,etc..
      Code:
      if ([B]([/B]myDataReader.GetString(0) [B]==[/B] empID[B])[/B] && [B]([/B]myDataReader.GetString(1) [B]==[/B] shiftID[B])[/B] && [B]([/B]myDataReader.GetFloat(2) [B]==[/B] Final11[B])[/B])
      {}

      Comment

      • isitha
        New Member
        • Dec 2010
        • 9

        #4
        guyz sry 4 da late reply,

        bentley :- thanx 4 ur help and i saw ur dock test article n downloaded ur examples...hope 2 use them in my projects....and also i gonna report microsoft abt U....suspect 4 software crimes...ha! ha! [i jst kidding]

        @subin :- thnx guy it workd pretty nice...n thnx agn 4 accepting my frnd req.

        Comment

        • HaLo2FrEeEk
          Contributor
          • Feb 2007
          • 404

          #5
          You sound extremely uneducated and immature when replying like you have. You might have gotten help with this problem, but in the future, most people will simply ignore your question entirely when they see sentences like:

          "guyz sry 4 da late reply"

          And

          "thnx guy it worked pretty nice...n thnx agn 4 accepting my frnd req."

          Do you realize that out of the 14 words in that second sentence, half of them are spelled incorrectly? If you want to be taken seriously, try using proper grammar, spelling, and punctuation in your postings.

          Comment

          Working...